<template>
  <nav class="app-topnav">
    <div class="container">
      <ul>
        <li>
          <a href="javascript:;"><i class="iconfont icon-user"></i>{{ account }}</a>
        </li>
        <li><a href="javascript:;" @click="logout">退出登录</a></li>
        <li><a href="javascript:;" @click="$router.push('/')">返回主页</a></li>
        <li><a href="javascript:;" @click="$router.push({ name: 'order' })">我的订单</a></li>
        <li><a href="javascript:;" @click="$router.push('/user/center')">会员中心</a></li>
      </ul>
    </div>
  </nav>
</template>
<script>
export default {
  name: 'TopNav',
  data() {
    return {
      account: '',
    }
  },
  created() {
    this.account = this.$store.state.user.account
  },
  methods: {
    logout() {
      window.sessionStorage.removeItem('token')
      window.localStorage.removeItem('user')
      this.$router.push('/')
      location.reload()
    },
  },
}
</script>
<style scoped lang="less">
.app-topnav {
  width: 100%;
  background: #333;
  ul {
    display: flex;
    height: 53px;
    justify-content: flex-end;
    align-items: center;
    li {
      list-style: none;
      a {
        padding: 0 15px;
        color: #cdcdcd;
        line-height: 1;
        text-decoration: none;
        display: inline-block;
        i {
          font-size: 14px;
          margin-right: 2px;
        }
        &:hover {
          color: #27ba9b;
        }
      }
      ~ li {
        a {
          border-left: 2px solid #666;
        }
      }
    }
  }
}
</style>
